<template>
  <div class="select-num-container">
    <div v-if="!selectNum ? selectItem.length : selectNum" class="select-num-container-text">
      <span class="select-num-container-title white-space-nowrap">已选</span>
      <span class="select-num-container-number">{{ !selectNum ? selectItem.length : selectNum }}</span>
      <span class="select-num-container-title">条</span>
      <slot />
      <el-button type="text" @click="clearSelect"><span class="el-icon-close"/></el-button>
    </div>
  </div>
</template>

<script>
import { showModal } from '@/utils/message';

export default {
  props: {
    btnText: {
      type: String,
      default: ''
    },
    selectItem: {
      type: Array,
      default: () => {
        return [];
      }
    },
    selectNum: {
      type: Number,
      default: 0
    }
  },
  methods: {
    clearSelect() {
      showModal('是否取消勾选？', '', {
        confirmButtonText: '确定',
        type: 'warning',
        showClose: false,
        center: true,
        iconClass: 'charge-icon'
      }).then(() => {
        this.$emit('clearMixinSelection');
      }).catch(() => {
        return false;
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.select-num-container {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  &-text {
    display: flex;
    align-items: center;
    height: 30px;
    width: auto;
    background: #fafafc;
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 5px 12px;
  }
  &-title {
    font-size: 14px;
    color: #666;
  }
  &-number {
    font-weight: 600;
    font-size: 14px;
    margin: 0 5px;
    color: #406eff;
  }
  .el-icon-close {
    font-size:14px;
    margin-left:5px;
    color: #666;
  }
  .el-icon-close:hover {
    color: #406EFF !important;
    font-weight: bold;
  }
}
</style>
